package com.tqjc.business.interactivewithscan.exception;

import com.tqjc.business.interactivewithscan.consts.ExceptionEnum;
import com.tqjc.business.interactivewithscan.consts.ScadaExceptionEnum;

/**
 * @program: C20005_Xianggang_new
 * @description: 异常处理
 * @author: Patienyon
 * @create: 2023-10-31 10:27
 **/
public class CustomException extends RuntimeException {
    private int code;
    private String msg;

//    public CustomException(ResultCode resultCode) {
//        super(resultCode.getMsg(), null, false, false);
//        this.code = resultCode.getCode();
//        this.msg = resultCode.getMsg();
//    }

    public CustomException(ExceptionEnum exceptionEnum) {
        this.code = exceptionEnum.getCode();
        this.msg = exceptionEnum.getMsg();
    }

    public CustomException(ExceptionEnum exceptionEnum,String msg) {
        this.code = exceptionEnum.getCode();
        this.msg = msg;
    }

    public CustomException(ScadaExceptionEnum scadaExceptionEnum) {
        this.code = scadaExceptionEnum.getCode();
        this.msg = "【" + scadaExceptionEnum.getDeviceName() + "】" + scadaExceptionEnum.getMsg();
    }

    public CustomException(int code, String msg) {
        super(msg, null, false, false);
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}

